package com.lee.lease.web.admin.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lee.lease.common.minio.MinioProperties;
import com.lee.lease.common.util.JwtUtil;
import com.lee.lease.model.entity.SystemUser;
import com.lee.lease.web.admin.mapper.SystemUserMapper;
import com.lee.lease.web.admin.service.SystemUserService;
import com.lee.lease.web.admin.vo.system.user.SystemUserItemVo;
import com.lee.lease.web.admin.vo.system.user.SystemUserQueryVo;
import io.minio.*;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import org.springframework.util.StringUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author liubo
 * @description 针对表【system_user(员工信息表)】的数据库操作Service实现
 * @createDate 2023-07-24 15:48:00
 */
@Service
public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemUser>
        implements SystemUserService {
    @Autowired
    private SystemUserMapper mapper;


    @Override
    public IPage<SystemUserItemVo> findByPage(IPage page, SystemUserQueryVo queryVo) {
        return mapper.findByPage(page, queryVo);
    }

    @Override
    public SystemUserItemVo findById(Long id) {
        return mapper.findById(id);
    }

    @Override
    public Boolean saveOrUpdateUser(SystemUser systemUser) {

        String password = systemUser.getPassword();
        if (StringUtils.hasText(password)) {
            systemUser.setPassword(DigestUtils.sha256Hex(password));
        }

        return super.saveOrUpdate(systemUser);
    }

}




